package chen.huai.jie.spring.xmlconfig.web.controller;

import chen.huai.jie.spring.xmlconfig.dto.UserDTO;
import chen.huai.jie.spring.xmlconfig.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户信息管理相关API")
@RestController
@RequestMapping(value = "/users", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UserController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;


    @ApiOperation(value = "根据用户Id获取用户信息.", notes = "根据用户ID获取用户信息")
    @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
    public UserDTO queryUserById(@PathVariable String userId) {
        logger.info("【queryUserById】执行的线程是:" + Thread.currentThread().getName());

//        userService.asyncMethod();
//
//        userService.addTeacher();

//        userService.addStudent();
        userService.addUser();

        UserDTO user = new UserDTO();
        user.setId(userId);
        user.setName("chenhuaijie");
        return user;
    }
}
